using Aurora.Discovery.HttpClient.Abstractions;
using Discovery.HttpClient.Consul.Options;
using Microsoft.Extensions.DependencyInjection;

namespace Discovery.HttpClient.Consul;

public class ConsulDiscoveryOptionsExtension : IDiscoveryOptionsExtension
{
    private readonly Action<ConsulDiscoveryOptions> _configure;

    public ConsulDiscoveryOptionsExtension(Action<ConsulDiscoveryOptions> configure)
    {
        _configure = configure;
    }

    public void AddServices(IServiceCollection services)
    {
        services.AddSingleton<IDiscoveryClient, ConsulDiscoveryClient>();
        services.Configure(_configure);
    }
}